	
		$(document).on("pageshow", function(){		
			var page = window.location.pathname; 
			if ( page.indexOf('index.html') > 0 ||  page.indexOf('.html') <= 0 ){
				loadCategories();
			}
			if ( page.indexOf('itemsMenu.html') > 0 ){
				loadQuestions();
			}
			if ( page.indexOf('contentViewer.html') > 0 ){
				loadContent();
			}
		});
		
	 function loadCategories(){
			if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.open("GET", "guiaEsp.xml", false);
			xmlhttp.send();
			xmlDoc=xmlhttp.responseXML;

			var x = xmlDoc.getElementsByTagName("category");
			var menuList = $('#categoriesList');
			var liText1 = "<li><a onClick=$.mobile.changePage('itemsMenu.html?selectedItem=";
			var liText2 = "',{transition:'none'}); >";
			
			for (i=0;i<x.length;i++)
				  {
				 
				  var name = x[i].getElementsByTagName("categoryName")[0].childNodes[0].nodeValue;
				  var id = x[i].getElementsByTagName("categoryId")[0].childNodes[0].nodeValue;
				  
				  menuList.append( liText1 + id + liText2 + name + "</a></li><br />");

				  }
			menuList.listview('refresh');
		};
		
		
		function loadQuestions() {
			var parameters = location.search.substring(1).split("&");
			var temp = parameters[0].split("=");
			nodeName = unescape(temp[1]);

			if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp = new XMLHttpRequest();
			}
			else {// code for IE6, IE5
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.open("GET", "guiaEsp.xml", false);
			xmlhttp.send();
			xmlDoc = xmlhttp.responseXML;
		
			var x = xmlDoc.getElementsByTagName("category");
			for (i = 0; i < x.length; i++) {
				if (x[i].getElementsByTagName("categoryId")[0].childNodes[0].nodeValue == nodeName) {
					var y = x[i].getElementsByTagName("item");
					for (j = 0; j < y.length; j++) {
								   
						var name = y[j].getElementsByTagName("title")[0].childNodes[0].nodeValue;
						var id = y[j].getElementsByTagName("id")[0].childNodes[0].nodeValue; 
						$('#itemsList').append("<li><a onClick=$.mobile.changePage('contentViewer.html?selectedItem=" + id + "',{transition:'none'}); >" + name + "</a></li><br />");			
					}
				}

			}
		$('ul').listview('refresh');
		};
	
	function loadContent(){

        var parameters = location.search.substring(1).split("&");
        var temp = parameters[0].split("=");
        nodeName = unescape(temp[1]);

        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.open("GET", "guiaEsp.xml", false);
        xmlhttp.send();
        xmlDoc = xmlhttp.responseXML;

        var x = xmlDoc.getElementsByTagName("item");
        for (i = 0; i < x.length; i++) {
            if (x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue == nodeName) {
                var description = x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue;
				$('#content').append("<p>" + description + "</p>");                
			}
		}


	};
	
	
	function searchEvent(){
			if (window.event && window.event.keyCode == 13) {
				search();
			}
		};
		
		
	function search(){
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.open("GET", "guiaEsp.xml", false);
		xmlhttp.send();
		xmlDoc=xmlhttp.responseXML;
		
		var items = xmlDoc.getElementsByTagName("item");
		
		var searchedText = $('#searchInput').textinput().val().toLowerCase();
		
		for (i=0;i<items.length;i++)
			  {				 
				var name = items[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
				if (name.toLowerCase().indexOf(searchedText) >= 0)
				{
					var id = items[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;				  
					$('#listResultTitle').append("<li><a href=itemsMenu.html?selectedItem=" + id + " rel='external'>" + name + "</a></li><br />");					
				}
				else
				{
					var description = items[i].getElementsByTagName("description")[0].childNodes[0].nodeValue;
					if (description.toLowerCase().indexOf(searchedText) >= 0)
					{
						var id = items[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;				  
						$('#listResultContent').append("<li><a href=itemsMenu.html?selectedItem=" + id + " rel='external'>" + name + "</a></li><br />");					
					}
				}
			  }
		$('#listResultTitle').listview('refresh');
		$('#listResultContent').listview('refresh');
	};	